﻿using MyCommunity.Models;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using System;


public class EventRegisterModel
{
    private Event obj;

    public EventRegisterModel() {
        this.obj = new Event();
    }

    public EventRegisterModel(Event obj)
    {
        this.Id = obj.Id;
        this.Title = obj.Title;
        this.Description = obj.Description;
        this.Addresse = obj.Addresse;
        this.ZipCode = (short)obj.ZipCode;
        this.City = obj.City;
        this.StartDate = obj.StartDate;
        this.EndDate = obj.EndDate;
    }

    public int Id { get; private set; }

    [Required]
    public string Title { get; set; }

    [Required]
    public string Description { get; set; }

    [Required]
    public string Addresse { get; set; }

    [Required]
    public short ZipCode { get; set; }

    [Required]
    public string City { get; set; }

    [Required]
    [DataType(DataType.DateTime)]
    //[Compare("Date", ErrorMessage = "StartDate must be on the same day as EndDate or earlier.")]
    public DateTime StartDate { get; set; }

    [Required]
    [DataType(DataType.DateTime)]
    //[Compare("Date", ErrorMessage = "EndDate must be on the same day as StartDate or later.")]
    public DateTime EndDate { get; set; }

    public void ApplyChanges(Event obj)
    {
        obj.Title = this.Title;
        obj.Description = this.Description;
        obj.Addresse = this.Addresse;
        obj.City = this.City;
        obj.ZipCode = this.ZipCode;
        obj.StartDate = this.StartDate;
        obj.EndDate = this.EndDate;
    }
}